package com.design.controller;

import com.design.model.BaseResult;
import com.design.model.UserLogOnRequest;
import com.design.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Api(tags = "【登录】-WEB端+APP端")
@RequestMapping("/login")
@CrossOrigin(origins = "*")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 登录接口
     * @param userLogOn 账号密码
     * @return token
     */
    @ApiOperation(value = "登录-WEB端+APP端")
    @PostMapping("/token")
    public BaseResult<Map<String,String>> token(@RequestBody UserLogOnRequest userLogOn){
        return loginService.token(userLogOn);
    }

    /**
     * 校验是否登录接口
     * @return 是否登录
     */
    @ApiOperation(value = "登录-校验是否登录")
    @PostMapping("/token-check")
    public BaseResult<Boolean> tokenCheck(@RequestHeader("token")String token){
        return loginService.tokenCheck(token);
    }

}
